package com.atguigu.edustatistics.controller;

import com.atguigu.commonutils.R;
import com.atguigu.edustatistics.service.StatisticsDailyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author cyt
 * @create 2020-06-04 8:19
 */

@Slf4j
@RequestMapping("/edustatistics")
@RestController
public class StatisticsController {
    @Autowired
    StatisticsDailyService statisticsDailyService;

    // 统计每天的注册人数
    @PostMapping("/createDataBydate/{day}")
    public R createDataBydate(@PathVariable("day") String day) {
        statisticsDailyService.createDataBydate(day);
        return R.ok();
    }

    // 生成图表
    @GetMapping("showChart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin, @PathVariable String end, @PathVariable String type) {
        Map<String, Object> map = statisticsDailyService.getChartData(begin, end, type);
        return R.ok().data(map);
    }
}
